package com.bjsxt;
/**设置线和名字*/

class SetName extends Thread{
    //在构造方法中设置 只适合于继承 Thread
    public SetName(String name){
        super(name);

    }
    @Override
    public void run() {
        System.out.println(this.getName());
    }
}
//通过setName()
class SetName2 implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
public class SetNameThread {
    public static void main(String[] args) {
        //在构造方法中设置
        SetName sn = new SetName("setOne");
        sn.start();
        Thread t = new Thread(new SetName2());
        t.setName("SetTwo");
        t.start();
    }
}
